package org.misalen.web.server.controllers;

import javax.servlet.http.HttpServletRequest;

import org.misalen.annotations.ControllerApi;
import org.misalen.annotations.InterfaceApi;
import org.misalen.web.server.config.ErrorCode;
import org.misalen.web.server.config.ServerResult;
import org.misalen.web.server.config.ServerUrl;
import org.misalen.web.server.result.Empty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = ServerUrl.ErrorControllerUrl)
@ControllerApi("错误信息")
public class ErrorController {

	@RequestMapping(value = "/400", method = { RequestMethod.GET })
	@InterfaceApi(value = "400", resultClass = Empty.class)
	public @ResponseBody ServerResult error400(HttpServletRequest request) {
		return ServerResult.error(ErrorCode.SYS_ERROR_CODE_400);
	}

	@RequestMapping(value = "/405", method = { RequestMethod.GET })
	@InterfaceApi(value = "405", resultClass = Empty.class)
	public @ResponseBody ServerResult error405(HttpServletRequest request) {
		return ServerResult.error(ErrorCode.SYS_ERROR_CODE_405);
	}

	@RequestMapping(value = "/404", method = { RequestMethod.GET })
	@InterfaceApi(value = "404", resultClass = Empty.class)
	public @ResponseBody ServerResult error404(HttpServletRequest request) {
		return ServerResult.error(ErrorCode.SYS_ERROR_CODE_404);
	}

	@RequestMapping(value = "/500", method = { RequestMethod.GET })
	@InterfaceApi(value = "500", resultClass = Empty.class)
	public @ResponseBody ServerResult error500(HttpServletRequest request) {
		return ServerResult.error(ErrorCode.SYS_ERROR_CODE_500);
	}

}
